import { actions, model } from "../mirror";
import { getState } from "../mirror/middleware";

export default model({
  name: 'first',
  initialState: { count: 0 },
  reducers: {
    count(state, { count }) {
      return { ...state, count };
    }
  },
  effects: {
    async addClick() {
      let state = getState();
      let { count } = state.first;
      actions.first.count({ count: count + 1 });
    },
    async decClick() {
      let state = getState();
      let { count } = state.first;
      actions.first.count({ count: count - 1 });
    }
  },
});

